import { createRouter, createWebHistory } from 'vue-router'
import { useAccountStore } from '@/stores/userInfo'
import { routeBaseURL } from '@/config/index'

const router = createRouter({
  // @ts-ignore
  history: createWebHistory(routeBaseURL),
  routes: [
    {
      path: '/',
      name: 'screen',
      component: () => import('../views/Screen/index.vue')
    }
  ]
})

router.beforeEach(async (to, from, next) => {
  // 获取参数
  const { token, type } = to.query
  if (token) {
    await useAccountStore().setAccessParam(token as string, type as string)
  }
  next()
})
export default router
